# Maintainer: omni <omni+alpine@hack.org>
pkgname=viu
pkgver=1.5.0
pkgrel=0
pkgdesc="Terminal image viewer"
# s390x: the trait `From<i32>` is not implemented for `u64` (in `terminal_size` crate)
arch="all !s390x !riscv64"
url="https://github.com/atanunq/viu"
license="MIT"
makedepends="cargo libsixel-dev cargo-auditable"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/atanunq/viu/archive/v$pkgver.tar.gz"

prepare() {
	default_prepare

	# Build against system-provided sixel.
	local target=$(rustc -vV | sed -n 's/host: //p')
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		sixel = { rustc-link-lib = ["sixel"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen --features sixel
}

check() {
	cargo test --frozen
}

package() {
	install -Dm0755 target/release/"$pkgname" -t "$pkgdir"/usr/bin
	install -Dm0644 README.md -t "$pkgdir"/usr/share/doc/"$pkgname"
	install -Dm0644 LICENSE-MIT -t "$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="
26dd7b129c4ec238aa8ff0a9fdca29daed019bd59117bbc7d485c04d7b77148fc0adc3b1e179569d825ed0cdc7b389466f97a24b9546b20109fbfa041a21f324  viu-1.5.0.tar.gz
"
